import instance from "./axiosConfig"
// 对后端返回的数据格式进行类型约束
interface IResponse<T = any> {
    code: number;
    data: T;
    message: string;
}
const http = {
    get: <T = any>(url: string, params?: object): Promise<IResponse<T>> => {
        return instance({
            url,
            method: 'GET',
            params
        })
    },
    post: <T = any>(url: string, data?: object): Promise<IResponse<T>> => {
        return instance({
            url,
            method: 'POST',
            data
        })
    },
    put: <T = any>(url: string, data?: object): Promise<IResponse<T>> => {
        return instance({
            url,
            method: 'PUT',
            data
        })
    },
    delete: <T = any>(url: string, data?: object): Promise<IResponse<T>> => {
        return instance({
            url,
            method: 'DELETE',
            data
        })
    },
}
export default http;